/**
 * @description: Try to find the first element which not repeat from given string
 * @function name: FindFirstNotRepeat
 * @argument: a string
 * @author: timlentse (tinglenxan@gmail.com)
 * @Date: 2014-11-05
 */
#include <iostream>

char FindFirstNotRepeat( char * aString )
{
	if ( *aString == '\0' )
	{
		return('\0');
	}
	int	size = 256;
	//the count-array stores the number of occurrences of each char 
	char	count[size];
	for ( int i = 0; i < 256; ++i )
	{
		count[i] = 0;
	}
	char* tmpString = aString;
	while ( *tmpString != '\0' )
		count[*tmpString++]++;
	tmpString = aString;
	while ( *tmpString != '\0' )
	{
		if ( count[*tmpString] == 1 )
		{
			return(*tmpString);
		}else
			++tmpString;
	}
}

//argv[1] as the inputstring
int main( int argc, char* argv[] )
{
	char theFirstNotRepeat;
	theFirstNotRepeat = FindFirstNotRepeat( argv[1] );
	std::cout << theFirstNotRepeat << std::endl;
	return(0);
}


